/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jsfclassic.controller.navigation;

import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.event.ActionEvent;
import org.primefaces.context.DefaultRequestContext;

/**
 *
 * @author cubika
 */
@ManagedBean(name = "navigator")
@SessionScoped
public class Navigator implements Serializable {

    private String currentPage = "/pages/page1.xhtml";
    private String previousPage = "";
   

    /** Creates a new instance of Navigator */
    public Navigator() {
    }

    public void navigateTo(String page) {
        previousPage = currentPage;
        setCurrentPage(page);
        DefaultRequestContext.getCurrentInstance().addPartialUpdateTarget("content");

    }
    public void navigateToPreviousPage(ActionEvent event){
       navigateTo(getPreviousPage());
    }

    public String getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(String currentPage) {
        this.currentPage = currentPage;
    }

    public String getPreviousPage() {
        return previousPage;
    }

    public void setPreviousPage(String previousPage) {
        this.previousPage = previousPage;
    }

   

   
}
